package com.qf.service;

import com.alibaba.druid.util.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qf.mapper.DtsRegionMapper;
import com.qf.pojo.DtsRegion;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * projectName: shop-manage
 *
 * @author: 元
 * time: 2021/9/16 0016 17:28
 * description:行政区划实现类
 */
@Service
public class RegionServiceImpl implements RegionService{

    @Autowired
    private DtsRegionMapper dtsRegionMapper;

    @Override
    public IPage<DtsRegion> selectByPage(Integer page, Integer limit, String name, Integer code) {
        //设置分页查询
        Page<DtsRegion> regionPage = new Page<>(page,limit);
        //设置查询条件
        QueryWrapper<DtsRegion> queryWrapper  = new QueryWrapper<>();
        if (!StringUtils.isEmpty(name)){
            queryWrapper.like("name",name);
        }
        if (code != null){
            queryWrapper.like("code",code);
        }
        IPage<DtsRegion> resultPage = dtsRegionMapper.selectPage(regionPage,queryWrapper );

        return  resultPage;


    }
}
